﻿<%@ Page Language="C#" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.Data" %>
<%    OleDbConnection conn = null;
try
{
    Response.ContentType = "text/xml";
    conn = DBOp.DbConn;
    OleDbCommand comm = conn.CreateCommand();
    comm.CommandText = "select count(*) as count1,avgdian from (select FIX((y07total + y08total) / 24 / 建筑面积 / 10) as avgdian from jz where y07total + y08total <> 0 and y07total + y08total <> '') group by avgdian";
    System.Data.DataTable dt = new System.Data.DataTable();
    OleDbDataAdapter oda = new OleDbDataAdapter(comm);    
    oda.Fill(dt);
    Random r = new Random(0);
     %><chart palette='2' caption='年代电量统计2007-2008' showBorder="1" subCaption="（单位：千瓦时）" shownames='1' showvalues='1' formatNumberScale='0' labelDisplay='ROTATE' slantLabels='1'  decimals='2' baseFontSize='12' baseFontFamily='宋体'>
     <%    foreach (DataRow dr in dt.Rows)    {
              if (dr["建筑年代"].ToString() == "50年以前")
              {
               %><set label='<%=dr["建筑年代"].ToString() %>' value='<%=dr["电量1"].ToString() %>' isSliced="<%=r.Next(2) %>"/>                                                    
               <% 
        }
              
          } 
    %>
    <%    foreach (DataRow dr in dt.Rows)    {
              string label = dr["建筑年代"].ToString();
              if (label != "2000-2004年代" && label != "50年以前" && label != "")
             {
               %><set label='<%=dr["建筑年代"].ToString() %>' value='<%=dr["电量1"].ToString() %>' isSliced="<%=r.Next(2) %>"/>                                                    
               <% }
          } %>
              <%    foreach (DataRow dr in dt.Rows)    {
              if (dr["建筑年代"].ToString() == "2000-2004年代")
              {
               %><set label='<%=dr["建筑年代"].ToString() %>' value='<%=dr["电量1"].ToString() %>' isSliced="<%=r.Next(2) %>"/>                                                    
               <% 
        }
              
          } 
    %>
     <%    foreach (DataRow dr in dt.Rows)    {
              if (dr["建筑年代"].ToString() == "")
              {
               %><set label='<%=dr["建筑年代"].ToString() %>' value='<%=dr["电量1"].ToString() %>' isSliced="<%=r.Next(2) %>"/>                                                    
               <% 
        }
              
          } 
    %>
          <styles>
         <definition>
            <style name='caption' type='font' font='宋体' size='16' color='000000' /> 
            <style name='label' type='font' font='宋体' size='12' Bold='1' color='000000' /> 
         </definition>
         <application>
            <apply toObject='DataLabels' styles='label' />
            <apply toObject='DataValues' styles='label' />
            <apply toObject='Caption' styles='caption' />
            <apply toObject='ToolTip' styles='label' />
            <apply toObject='Legend' styles='label' />
            <apply toObject='ToolTip' styles='label' />
            <apply toObject='ToolTip' styles='label' />
         </application>   
    </styles> 
</chart>
<% 
    }
catch (Exception ex) { 
    %><%=ex.Message %><%
}
    finally{
    if(conn != null)
    conn.Close();} %>